package com.sc.oa.base;

import java.lang.reflect.ParameterizedType;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.sc.oa.entity.SysMenu;
import com.sc.oa.service.SysMenuService;
import com.sc.oa.service.impl.IDepartmentService;
import com.sc.oa.service.impl.IGroupInfoService;
import com.sc.oa.service.impl.IPositionService;
import com.sc.oa.service.impl.ISysFunctionService;
import com.sc.oa.service.impl.ISysMenuService;
import com.sc.oa.service.impl.ISysRoleService;
import com.sc.oa.service.impl.IUserAccoutService;
import com.sc.oa.service.impl.IUserInfoService;

public abstract class BaseAction<T> extends ActionSupport implements ModelDriven<T>{
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	//service 的映射
	protected ISysFunctionService functionservice;
	protected ISysMenuService menuservice;
	protected ISysRoleService roleservice;
	protected IUserAccoutService useraccoutservice;
	protected IUserInfoService userinfoservice;
	protected IGroupInfoService groupservice;
	protected IDepartmentService departmentservice;
	protected IPositionService positionservice;
	
	protected SysMenu menu;
	
	//list
	protected List list,list2;
	
	protected String msg;
	protected Pager p = new Pager();
	


	protected T model;
	
	/*
	 * 通过映射得到model的信息类
	 */
	public BaseAction(){
		
		try {
			ParameterizedType pt = (ParameterizedType) this.getClass().getGenericSuperclass();
			Class clazz = (Class) pt.getActualTypeArguments()[0];
			//通过反射生成的model实例
			model = (T) clazz.newInstance();
		} catch (InstantiationException e) {
			throw new RuntimeException(e);
		} catch (IllegalAccessException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	
	@Override
	public T getModel(){
		return model;
	}
	
	public ISysFunctionService getFunctionservice() {
		return functionservice;
	}

	public void setFunctionservice(ISysFunctionService functionservice) {
		this.functionservice = functionservice;
	}

	public ISysMenuService getMenuservice() {
		return menuservice;
	}

	public void setMenuservice(ISysMenuService menuservice) {
		this.menuservice = menuservice;
	}

	public ISysRoleService getRoleservice() {
		return roleservice;
	}

	public void setRoleservice(ISysRoleService roleservice) {
		this.roleservice = roleservice;
	}

	public IUserAccoutService getUseraccoutservice() {
		return useraccoutservice;
	}

	public void setUseraccoutservice(IUserAccoutService useraccoutservice) {
		this.useraccoutservice = useraccoutservice;
	}

	public IUserInfoService getUserinfoservice() {
		return userinfoservice;
	}

	public void setUserinfoservice(IUserInfoService userinfoservice) {
		this.userinfoservice = userinfoservice;
	}

	public IGroupInfoService getGroupservice() {
		return groupservice;
	}

	public void setGroupservice(IGroupInfoService groupservice) {
		this.groupservice = groupservice;
	}

	public IDepartmentService getDepartmentservice() {
		return departmentservice;
	}

	public void setDepartmentservice(IDepartmentService departmentservice) {
		this.departmentservice = departmentservice;
	}
	

	public IPositionService getPositionservice() {
		return positionservice;
	}

	public void setPositionservice(IPositionService positionservice) {
		this.positionservice = positionservice;
	}

	public List getList() {
		return list;
	}

	public void setList(List list) {
		this.list = list;
	}

	public List getList2() {
		return list2;
	}

	public void setList2(List list2) {
		this.list2 = list2;
	}

	public String getMsg() {
		return msg;
	}

	public void setMsg(String msg) {
		this.msg = msg;
	}

	public Pager getP() {
		return p;
	}

	public void setP(Pager p) {
		this.p = p;
	}


	public SysMenu getMenu() {
		return menu;
	}


	public void setMenu(SysMenu menu) {
		this.menu = menu;
	}
	
}
